﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DQYT.HTDZ.BLL;
using System.Data;
using DQYT.HTDZ.Common;
using DQYT.HTDZ.Model;
using DQYT.HTDZ.Web;

namespace SkWeb.Handlers
{
    public partial class DJSKCBHandler : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string resultJson = string.Empty;

            int pageSize, pageIndex, recordCount;


            string format = "\"total\":{0}, \"rows\":{1}";

            string wellCode = Uri.UnescapeDataString(Request.Form["jh"]);
            int.TryParse(Request.Form["rows"], out pageSize);
            int.TryParse(Request.Form["page"], out pageIndex);
            if (pageSize == 0) pageSize = 15;
            if (pageIndex == 0) pageIndex = 1;
            recordCount = 0;

            if (!string.IsNullOrWhiteSpace(wellCode))
                wellCode = wellCode.Replace("'", "").Replace("\\", "").Replace("&", "");

            SkgysjbBLL skgysjbBLL = new SkgysjbBLL();
            DataTable table = skgysjbBLL.getSKGYSJBData("", wellCode, pageSize, pageIndex, out recordCount);
            resultJson = JsonHelper.ToJson(table);
            resultJson = "{" + string.Format(format, recordCount,
                string.IsNullOrWhiteSpace(resultJson) ? "[]" : resultJson) + "}";

            Response.ContentType = "text/json";
            Response.Write(resultJson);
        }
    }
}